local lunjaing = fk.CreateSkill{
    name = "lingling__lunjiang",
}
Fk:loadTranslationTable{
    ["lingling__lunjiang"] = "论将",
    [":lingling__lunjiang"] = "出牌阶段限一次，你可以令所有角色各重铸一张牌，若有【桃】，你摸两张牌，若没有，本阶段你使用牌无法抵消。",
    ["#askForLunjiang"] = "论将：你可以选择重铸一张牌",
    ["@@lingling__lunjiang-phase"] = "论将 用牌强命"
}

lunjaing:addEffect("active", {
    card_num = 0,
    target_num = 0,
    card_filter = Util.FalseFunc,
    target_filter = Util.FalseFunc,
    max_phase_use_time = 1,
    can_use = function (self, player)
        return self:withinTimesLimit(player, Player.HistoryPhase)
    end,
    on_use = function (self, room, effect)
        local player = effect.from
        local targets = room:getAlivePlayers(true)
        local extraData = {
            num = 1,
            min_num = 1,
            include_equip = true,
            pattern = ".",
            reason = lunjaing.name,
        }
        local prompt = "#askForLunjiang"
        local dat = { "choose_cards_skill", prompt, false, extraData }
        local req = Request:new(targets, "AskForUseActiveSkill")
        req.focus_text = "lingling__lunjiang"
        for _, to in ipairs(targets) do
            req:setData(to, dat)
        end

        local names = {}
        for _, p in ipairs(targets) do
            local cids
            if p.reply_ready then
                local replyCard = req:getResult(p).card
                cids = table.random(replyCard.subcards, 1)
            else
                cids = table.random(p:getCardIds("he"), 1)
            end
            table.insertIfNeed(names, Fk:getCardById(cids[1], true).trueName)
            room:recastCard(cids, p, lunjaing.name)
        end

        if table.contains(names, "peach") then
            player:drawCards(2, lunjaing.name)
        else
            room:setPlayerMark(player, "@@lingling__lunjiang-phase", 1)
        end
    end,
})

lunjaing:addEffect(fk.CardUsing, {
    anim_type = "offensive",
    is_delay_effect = true,
    can_trigger = function (self, event, target, player, data)
        return target == player and player:getMark("@@lingling__lunjiang-phase") ~= 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        data.unoffsetableList = table.simpleClone(player.room.players)
    end,
})

return lunjaing